<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>FLV 播放器</title>
    <script src="https://cdn.jsdelivr.net/npm/flv.js@1.5.0/dist/flv.min.js"></script>
    <style>
        body, html {
            margin: 0;
            padding: 0;
            height: 100%;
            overflow: hidden;
        }

        #videoElement {
            width: 100%;
            height: 100%;
            object-fit: cover; /* 确保视频充满屏幕，按比例缩放 */
        }
    </style>
</head>
<body>

    <video id="videoElement" controls autoplay muted></video>

    <script>
        const urlParams = new URLSearchParams(window.location.search);
        const videoUrl = urlParams.get('video'); 

        const defaultUrl = 'http://10.202.28.39:8866/live?url=rtsp://admin:pwd@172.14.22.64:554/Streaming/Channels/101';
        const finalUrl = videoUrl || defaultUrl;  

        var videoElement = document.getElementById('videoElement');
        if (flvjs.isSupported()) {
            var flvPlayer = flvjs.createPlayer({
                type: 'flv',
                url: finalUrl, 
                isLive: true,    // 设置为实时流（如果是直播）
                enableStashBuffer: false,  
                autoStartLoad: true,  
                seekType: 'range',  
            });
            
            flvPlayer.attachMediaElement(videoElement);
            
            flvPlayer.load();
            flvPlayer.play();
        } else {
            console.error('浏览器不支持 FLV.js 或未提供有效的 "video" 参数');
        }
    </script>

</body>
</html>
